package br.perfiman.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

/**
 *
 * @author Wagner Costa
 * @since 27/12/2007
 * @version 1.0
 *
 */
@Entity
public class Bill implements AbstractEntity{
	private static final long serialVersionUID = 6732806167803281168L;

	public static final Integer STATUS_OPENED = 1;
	public static final Integer STATUS_DONE = 2;

	public static final Integer TYPE_BILL = 1;
	public static final Integer TYPE_DEPOSIT = 2;

	public static final Integer PAYMENT_METHOD_CASH = 1;
	public static final Integer PAYMENT_METHOD_CREDIT_CARD = 2;

	@Id
    @GeneratedValue
    protected Long id;

	@Column(nullable=false)
	protected Integer type;

    @Column(length=100, nullable=false)
    protected String description;

    @Column(name="payment_method", nullable=false)
    protected Integer paymentMethod;

    @Column(name="movement_date", nullable=false)
    protected Date movementDate;

    @Column(name="payment_date")
    protected Date paymentDate;

    @Column(name="expiration_date", nullable=false)
    protected Date expirationDate;

    @ManyToOne
    protected Account account;

    @ManyToOne
    protected CreditCard creditCard;

    @ManyToOne(optional=false)
    protected Category category;

    @ManyToOne(optional=false)
    protected Person involved;

    @Column(nullable=false)
    protected Double ammount;

    @Column(nullable=false)
    protected Integer status;

    @Column(length=255)
    protected String comments;

	@Override
	public String toString() {
		StringBuilder b = new StringBuilder();
		b.append("id: ").append(getId());
		b.append("; Description: ").append(getDescription());
		b.append("; type: ").append(getType());
		b.append("; paymentMethod: ").append(getPaymentMethod());
		b.append("; movementDate: ").append(getMovementDate());
		b.append("; paymentDate: ").append(getPaymentDate());
		b.append("; expirationDate: ").append(getExpirationDate());
		b.append("; ammount: ").append(getAmmount());
		b.append("; status: ").append(getStatus());
		b.append("; comments: ").append(getComments());
		b.append("; [account: ").append(getAccount());
		b.append("]; [creditcard: ").append(getCreditCard());
		b.append("]; [category: ").append(getCategory());
		b.append("]; [person: ").append(getInvolved()).append("]");
		return b.toString();
	}

	public Object getEntityId() {
		return getId();
	}

	public Account getAccount() {
		return account;
	}

	public Double getAmmount() {
		return ammount;
	}

	public Category getCategory() {
		return category;
	}

	public String getComments() {
		return comments;
	}

	public CreditCard getCreditCard() {
		return creditCard;
	}

	public String getDescription() {
		return description;
	}

	public Date getExpirationDate() {
		return expirationDate;
	}

	public Long getId() {
		return id;
	}

	public Person getInvolved() {
		return involved;
	}

	public Date getMovementDate() {
		return movementDate;
	}

	public Date getPaymentDate() {
		return paymentDate;
	}

	public Integer getPaymentMethod() {
		return paymentMethod;
	}

	public Integer getStatus() {
		return status;
	}

	public Integer getType() {
		return type;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	public void setAmmount(Double ammount) {
		this.ammount = ammount;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public void setCreditCard(CreditCard creditCard) {
		this.creditCard = creditCard;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setExpirationDate(Date expirationDate) {
		this.expirationDate = expirationDate;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setInvolved(Person involved) {
		this.involved = involved;
	}

	public void setMovementDate(Date movementDate) {
		this.movementDate = movementDate;
	}

	public void setPaymentDate(Date paymentDate) {
		this.paymentDate = paymentDate;
	}

	public void setPaymentMethod(Integer paymentMethod) {
		this.paymentMethod = paymentMethod;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public void setType(Integer type) {
		this.type = type;
	}
}